/*****************************************************
** Author:
** Date: 2019-07-25
*
*****************************************************/

#ifndef __ADS1256_H_
#define __ADS1256_H_

#ifdef __cplusplus
extern "C"{
#endif


enum
{
	ADS1256_GPIO_LEVEL_LOW,
	ADS1256_GPIO_LEVEL_HIGH,
};

typedef struct
{
	unsigned char   (*spi_transfer_byte)(unsigned char val);
    void            (*spi_csn_level)(unsigned char level);
    void            (*reset_level)(unsigned char level);
    void            (*sync_pdwn_level)(unsigned char level);
    int             (*drdy_level)(void);
    void            (*delay_ms)(unsigned int ms);
    void 			(*delay_us)(unsigned int us);
} ads1256_obj_t;


void ads1256_if_init(ads1256_obj_t *obj);
int ads1256_read_data(void);
unsigned char ads1256_read_status(void);
unsigned char ads1256_chipid(void);
void ads1256_cfg(int acal, int bufen, int gain, int drate);
int ads1256_read_single_ended_channel(int chan);
int ads1256_read_diff_channel(int chan_p, int chan_n);
int ads1256_scan_single_ended_channels(int channels[], int chan_num, int data[]);
int ads1256_scan_diff_channels(int chan_p[], int chan_n[], int chan_num, int data[]);
void ads1256_read_single_ended_channel_continuous(int chan, int spl_num, int data[], int us_time[]);
void ads1256_read_diff_channel_continuous(int chan_p, int chan_n, int spl_num, int data[], int us_time[]);

#ifdef __cplusplus
}
#endif

#endif /* __ADS1256_H_ */

